********************************************
*****************OVERVIEW*******************
********************************************

Dataverse Replication materials: "Elite Cues and Economic Policy Attitudes: The Mediating Role of Economic Hardship" by Charlotte Cavaille and Anja Neundorf

Below is a description of the data files, the analysis files, and the codebook, as well as step-by-step instructions for the replication of the content of all figures and associated discussion in the article and Supporting Information.


********************************************
***********COMPUTER ENVIRONMENT**************
********************************************

Operating system: Mac OS Monterey (2.4 GHz Quad-Core Intel Core i5; 8 GB 1600 MHz DDR3)
Statistical software versions: Stata/MP 16.1 for Mac (64-bit Intel) and LatentGOLD 5.1 (syntax version)
Stata Packages used in analysis: outreg2


********************************************
**********REPLICATING THE ANALYSIS**********
********************************************

************
**Necessary Files
************

Code:
BHPS_genData.do: Creates the working file from the are BHPS data
Recoding and Explorative.do: Recoding and Explorative analysis of BHPS working file. Prepare working files for LatentGOLD. 
Main Latent Markov models.lgs: Syntax file for LatentGOLD to replicate main models in manuscript and appendix
Labour + polint.lgs: Syntax file for LatentGOLD to replicate models on Labour sub-sample (Fig 3)
Labour sample.lgs: Syntax file for LatentGOLD to replicate models on Labour sub-sample (appendix)
PoBe_Manuscript.do: Code to replicate all tables and figures presented in the manuscript 
PoBe_Appendix.do: Code to replicate all tables and figures presented in the appendix

Data files (should be saved in Data-subfolder):
transprobs_general.dta: Transition probability data for Figures 2 + A5
transprobs_polint_pid.dta: Transition probability data for Figure 3
transprobs_finsit.dta: Transition probability data for Figure 4
transprobs_income.dta: Transition probability data for Figure 4
transprobs_jobsec.dta: Transition probability data for Figure 4
transprobs_unemp.dta: Transition probability data for Figure 4
transprobs_polint.dta: Transition probability data for Figure A6.A
transprobs_pid.dta: Transition probability data for Figure A6.B  
classifications.dta: Classification data post-Latent Markov model
transprobs_gender.dta: Transition probability data for Figure A12  


************
**Instructions and Further Description
************

1. Download all of the necessary files to your computer. Create three sub-folder: 1) Data, 2) Graphs, 3) Results. Save the .dta files in the Data-folder. 

2. Set your working directory in Stata to the folder in which you stored all of the necessary files and sub-folders. 

3. Create BHPS working file following the instructions below ("DATA PREPARATION")

4. Run analysis in LatentGOLD following the instructions below ("STEPS IN LATENTGOLD")

5. Replicate figures and tables presented in main paper using �PoBe_Manuscript.do�. 

6. Replicate figures and tables presented in main paper using �PoBe_Manuscript.do�. 


********************************************
****************DATA PREPARATION *****************
********************************************

We are not able to distribute the BHPS data used in the article due to copyright issues. Here we provide steps of creating the working file used in the article. 

1. Download BHPS data: You need to download the data "British Household Panel Survey: Waves 1-18, 1991-2009" from: https://beta.ukdataservice.ac.uk/datacatalogue/studies/study?id=5151#!/details 

2. Save data in one folder called "BHPS" on your computer and add directory to do-file "BHPS_genData.do" (line 11). In your BHPS folder, you should add two sub-folders: 1) "original", where you save the raw BHPS datafilee that you downloaded and 2) "temp", where you will save temporary files while creating the working files. 

3. Save final working file: Once you ran the do-file, save the working file on your computer. For this change the directory in line 265. 

4. Run do-file "Recoding and Explorative.do" to recode variables and explore the data. This file also creates the working files, which will be read into LatentGold. Here you need to change the directory in line 9 to your working folder.

5. The following Stata-files need to be transferred to SPSS format to be read into LatentGOLD.


********************************************
****************STEPS IN LATENTGOLD *****************
********************************************

Models were estimated using LatentGOLD. From there several results had to be exported to create the tables and figures presented in the table. Here we outline the steps to take in LatentGOLD.

1. Before loading the syntax-files into LatentGOLD open with text-reader to change the path, where you have saved the SPSS files created in step 5 - Data Prep.  

2. First run the syntax-file "Main Latent Markov models.lgs" -> Click on Data name at the top -> Go to Menu "Model" -> Select "Estimate All"

3. For each separate model, it is important to first interpret which latent class number corresponds to which latent economic preference (e.g. left-wing), which will correspond to the mean values of the indicators in the tab "Profile". The lowest average will be the left class, the highest the right class.

4. Results to replicate the following tables and figures:

Table 1 - Manuscript: Go to Model "LM (3)" -> Go to tap "Profile" -> Copy numbers for "Size" (corresponds to Proportions") -> Copy numbers at the bottom for transition probabilities. 

Figure 2 - Manuscript + Figure A5 in Appendix: Go to Model "LM (3)" -> Go to tap "EstimatedValues-Model" -> right-click -> select "Standard Errors" -> Copy Table time, ideol[-1], ideol -> Create new Stata data (transprobs_general.dta) -> Run code in "PoBe_Manuscript.do" and "PoBe_Appendix.do"

Table 2 - Manuscript : Go to Models "LM + unempl", "LM + inc_drop", "LM + finest" and "LM + jobs" in turns -> Go to tap Parameters -> Select coefficients and standard errors for IVs on latent classes.

Figure 4 - Manuscript + Figure A7-A9 in Appendix: Go to Models "LM + unempl", "LM + inc_drop", "LM + finest" and "LM + jobs" in turns -> Go to tap "EstimatedValues-Model" -> right-click -> select "Standard Errors" -> Copy Table time, ideol[-1], ideol -> Create new Stata data for each IV -> Run code in "PoBe_Manuscript.do" and "PoBe_Appendix.do"

Table A4 - Appendix: Click on Data name at the top -> Select comparative model fit stats for LM (1) to LM (5).

Table A5 - Appendix: Go to Model "LM (3)" -> Go to tap "Profile" -> Copy numbers for latent class estimators for each survey item (opsoc_a_rev to opsoc_f_rev)

Table A6 - Appendix: Go to Model "LM (3)" -> Go to tap Parameters -> Select coefficients and standard errors for IVs on latent classes at t=0 (ideol[=0]).



5. Run the syntax-file "Labour + polint.lgs" -> Click on Data name at the top -> Go to Menu "Model" -> Select "Estimate All" 

6. Results to replicate Figure 3 - Manuscript: Go to Model "LM" -> Go to tap "EstimatedValues-Model" -> right-click -> select "Standard Errors" -> Copy Table time, ideol[-1], ideol -> Create new Stata data -> Run code in "PoBe_Manuscript.do" and "PoBe_Appendix.do"


7. Run the syntax-file "Labour sample.lgs" -> Click on Data name at the top -> Go to Menu "Model" -> Select "Estimate All" 

8. Results to replicate Table A7 - Appendix: Go to Models "LM + unempl", "LM + inc_drop", "LM + finest" and "LM + jobs" in turns -> Go to tap Parameters -> Select coefficients and standard errors for IVs on latent classes.


9. Run the syntax-file "Placebo gender.lgs" -> Click on Data name at the top -> Go to Menu "Model" -> Select "Estimate All" 

10. Results to replicate Figure A12 - Appendix: Go to tap "EstimatedValues-Model" -> right-click -> select "Standard Errors" -> Copy Table time, ideol[-1], ideol -> Create new Stata data -> Run code in "PoBe_Appendix.do"


********************************************
****************OTHER FILES*****************
********************************************
Replication_readme.txt: This file


********************************************
************REPLICATION CONTACT*************
********************************************

Anja Neundorf
University of Glasgow
Anja.Neundorf@glasgow.ac.uk
http://www.aneundorf.net